"""
内容相关Schema
"""
from typing import Optional, List
from datetime import datetime
from pydantic import BaseModel


# Banner Schemas
class BannerBase(BaseModel):
    """Banner基础"""
    title: Optional[str] = None
    subtitle: Optional[str] = None
    image_url: str
    link_url: Optional[str] = None
    sort_order: int = 0
    status: int = 1


class BannerCreate(BannerBase):
    """创建Banner"""
    pass


class BannerUpdate(BaseModel):
    """更新Banner"""
    title: Optional[str] = None
    subtitle: Optional[str] = None
    image_url: Optional[str] = None
    link_url: Optional[str] = None
    sort_order: Optional[int] = None
    status: Optional[int] = None


class BannerResponse(BannerBase):
    """Banner响应"""
    id: int
    created_at: datetime
    updated_at: datetime
    
    class Config:
        from_attributes = True


# Product Schemas
class ProductBase(BaseModel):
    """产品基础"""
    category_id: Optional[int] = None
    name: str
    subtitle: Optional[str] = None
    cover_image: Optional[str] = None
    images: Optional[List[str]] = None
    summary: Optional[str] = None
    content: Optional[str] = None
    features: Optional[List[dict]] = None
    specifications: Optional[dict] = None
    video_url: Optional[str] = None
    sort_order: int = 0
    status: int = 1
    seo_title: Optional[str] = None
    seo_keywords: Optional[str] = None
    seo_description: Optional[str] = None


class ProductCreate(ProductBase):
    """创建产品"""
    pass


class ProductUpdate(BaseModel):
    """更新产品"""
    category_id: Optional[int] = None
    name: Optional[str] = None
    subtitle: Optional[str] = None
    cover_image: Optional[str] = None
    images: Optional[List[str]] = None
    summary: Optional[str] = None
    content: Optional[str] = None
    features: Optional[List[dict]] = None
    specifications: Optional[dict] = None
    video_url: Optional[str] = None
    sort_order: Optional[int] = None
    status: Optional[int] = None
    seo_title: Optional[str] = None
    seo_keywords: Optional[str] = None
    seo_description: Optional[str] = None


class ProductResponse(ProductBase):
    """产品响应"""
    id: int
    view_count: int
    created_at: datetime
    updated_at: datetime
    
    class Config:
        from_attributes = True


# News Schemas
class NewsBase(BaseModel):
    """新闻基础"""
    category_id: Optional[int] = None
    title: str
    subtitle: Optional[str] = None
    cover_image: Optional[str] = None
    summary: Optional[str] = None
    content: str
    author: Optional[str] = None
    source: Optional[str] = None
    tags: Optional[str] = None
    is_top: int = 0
    status: int = 1
    publish_time: Optional[datetime] = None
    seo_title: Optional[str] = None
    seo_keywords: Optional[str] = None
    seo_description: Optional[str] = None


class NewsCreate(NewsBase):
    """创建新闻"""
    pass


class NewsUpdate(BaseModel):
    """更新新闻"""
    category_id: Optional[int] = None
    title: Optional[str] = None
    subtitle: Optional[str] = None
    cover_image: Optional[str] = None
    summary: Optional[str] = None
    content: Optional[str] = None
    author: Optional[str] = None
    source: Optional[str] = None
    tags: Optional[str] = None
    is_top: Optional[int] = None
    status: Optional[int] = None
    publish_time: Optional[datetime] = None
    seo_title: Optional[str] = None
    seo_keywords: Optional[str] = None
    seo_description: Optional[str] = None


class NewsResponse(NewsBase):
    """新闻响应"""
    id: int
    view_count: int
    created_at: datetime
    updated_at: datetime
    
    class Config:
        from_attributes = True


# Category Schemas
class CategoryBase(BaseModel):
    """分类基础"""
    name: str
    sort_order: int = 0


class CategoryCreate(CategoryBase):
    """创建分类"""
    pass


class CategoryResponse(CategoryBase):
    """分类响应"""
    id: int
    created_at: datetime
    
    class Config:
        from_attributes = True


# Case Schemas
class CaseBase(BaseModel):
    """案例基础"""
    title: str
    client_name: Optional[str] = None
    industry: Optional[str] = None
    cover_image: Optional[str] = None
    images: Optional[List[str]] = None
    summary: Optional[str] = None
    background: Optional[str] = None
    challenge: Optional[str] = None
    solution: Optional[str] = None
    result: Optional[str] = None
    technologies: Optional[str] = None
    sort_order: int = 0
    status: int = 1


class CaseCreate(CaseBase):
    """创建案例"""
    pass


class CaseUpdate(BaseModel):
    """更新案例"""
    title: Optional[str] = None
    client_name: Optional[str] = None
    industry: Optional[str] = None
    cover_image: Optional[str] = None
    images: Optional[List[str]] = None
    summary: Optional[str] = None
    background: Optional[str] = None
    challenge: Optional[str] = None
    solution: Optional[str] = None
    result: Optional[str] = None
    technologies: Optional[str] = None
    sort_order: Optional[int] = None
    status: Optional[int] = None


class CaseResponse(CaseBase):
    """案例响应"""
    id: int
    view_count: int
    created_at: datetime
    updated_at: datetime
    
    class Config:
        from_attributes = True


# Solution Schemas
class SolutionBase(BaseModel):
    """解决方案基础"""
    title: str
    industry: Optional[str] = None
    cover_image: Optional[str] = None
    summary: Optional[str] = None
    pain_points: Optional[str] = None
    solution_content: Optional[str] = None
    architecture_image: Optional[str] = None
    advantages: Optional[str] = None
    related_cases: Optional[List[int]] = None
    sort_order: int = 0
    status: int = 1


class SolutionCreate(SolutionBase):
    """创建解决方案"""
    pass


class SolutionUpdate(BaseModel):
    """更新解决方案"""
    title: Optional[str] = None
    industry: Optional[str] = None
    cover_image: Optional[str] = None
    summary: Optional[str] = None
    pain_points: Optional[str] = None
    solution_content: Optional[str] = None
    architecture_image: Optional[str] = None
    advantages: Optional[str] = None
    related_cases: Optional[List[int]] = None
    sort_order: Optional[int] = None
    status: Optional[int] = None


class SolutionResponse(SolutionBase):
    """解决方案响应"""
    id: int
    view_count: int
    created_at: datetime
    updated_at: datetime
    
    class Config:
        from_attributes = True


# Job Schemas
class JobBase(BaseModel):
    """招聘职位基础"""
    title: str
    department: Optional[str] = None
    location: Optional[str] = None
    job_type: Optional[str] = None
    salary_range: Optional[str] = None
    experience_required: Optional[str] = None
    education_required: Optional[str] = None
    description: Optional[str] = None
    responsibilities: Optional[str] = None
    requirements: Optional[str] = None
    benefits: Optional[str] = None
    headcount: int = 1
    status: int = 1


class JobCreate(JobBase):
    """创建职位"""
    pass


class JobUpdate(BaseModel):
    """更新职位"""
    title: Optional[str] = None
    department: Optional[str] = None
    location: Optional[str] = None
    job_type: Optional[str] = None
    salary_range: Optional[str] = None
    experience_required: Optional[str] = None
    education_required: Optional[str] = None
    description: Optional[str] = None
    responsibilities: Optional[str] = None
    requirements: Optional[str] = None
    benefits: Optional[str] = None
    headcount: Optional[int] = None
    status: Optional[int] = None


class JobResponse(JobBase):
    """职位响应"""
    id: int
    created_at: datetime
    updated_at: datetime
    
    class Config:
        from_attributes = True


# ServicePackage Schemas
class ServicePackageBase(BaseModel):
    """技术服务套餐基础"""
    name: str
    subtitle: Optional[str] = None
    package_type: Optional[str] = None
    price: Optional[str] = None
    original_price: Optional[str] = None
    price_unit: Optional[str] = "元/年"
    description: Optional[str] = None
    features: Optional[List[str]] = None
    service_items: Optional[List[str]] = None
    suitable_for: Optional[str] = None
    is_recommended: int = 0
    sort_order: int = 0
    status: int = 1


class ServicePackageCreate(ServicePackageBase):
    """创建技术服务套餐"""
    pass


class ServicePackageUpdate(BaseModel):
    """更新技术服务套餐"""
    name: Optional[str] = None
    subtitle: Optional[str] = None
    package_type: Optional[str] = None
    price: Optional[str] = None
    original_price: Optional[str] = None
    price_unit: Optional[str] = None
    description: Optional[str] = None
    features: Optional[List[str]] = None
    service_items: Optional[List[str]] = None
    suitable_for: Optional[str] = None
    is_recommended: Optional[int] = None
    sort_order: Optional[int] = None
    status: Optional[int] = None


class ServicePackageResponse(ServicePackageBase):
    """技术服务套餐响应"""
    id: int
    created_at: Optional[datetime] = None
    updated_at: Optional[datetime] = None
    
    class Config:
        from_attributes = True


# CustomPackage Schemas
class CustomPackageBase(BaseModel):
    """定制开发套餐基础"""
    name: str
    subtitle: Optional[str] = None
    category: Optional[str] = None
    price_range: Optional[str] = None
    duration: Optional[str] = None
    team_size: Optional[str] = None
    description: Optional[str] = None
    features: Optional[List[str]] = None
    tech_stack: Optional[List[str]] = None
    deliverables: Optional[List[str]] = None
    service_process: Optional[List[dict]] = None
    case_studies: Optional[List[dict]] = None
    is_hot: int = 0
    sort_order: int = 0
    status: int = 1


class CustomPackageCreate(CustomPackageBase):
    """创建定制开发套餐"""
    pass


class CustomPackageUpdate(BaseModel):
    """更新定制开发套餐"""
    name: Optional[str] = None
    subtitle: Optional[str] = None
    category: Optional[str] = None
    price_range: Optional[str] = None
    duration: Optional[str] = None
    team_size: Optional[str] = None
    description: Optional[str] = None
    features: Optional[List[str]] = None
    tech_stack: Optional[List[str]] = None
    deliverables: Optional[List[str]] = None
    service_process: Optional[List[dict]] = None
    case_studies: Optional[List[dict]] = None
    is_hot: Optional[int] = None
    sort_order: Optional[int] = None
    status: Optional[int] = None


class CustomPackageResponse(CustomPackageBase):
    """定制开发套餐响应"""
    id: int
    created_at: Optional[datetime] = None
    updated_at: Optional[datetime] = None
    
    class Config:
        from_attributes = True


# PackageFeature Schemas
class PackageFeatureBase(BaseModel):
    """套餐功能对照基础"""
    feature_name: str
    feature_category: Optional[str] = None
    description: Optional[str] = None
    basic_plan: Optional[str] = None
    standard_plan: Optional[str] = None
    professional_plan: Optional[str] = None
    enterprise_plan: Optional[str] = None
    sort_order: int = 0
    status: int = 1


class PackageFeatureCreate(PackageFeatureBase):
    """创建套餐功能对照"""
    pass


class PackageFeatureUpdate(BaseModel):
    """更新套餐功能对照"""
    feature_name: Optional[str] = None
    feature_category: Optional[str] = None
    description: Optional[str] = None
    basic_plan: Optional[str] = None
    standard_plan: Optional[str] = None
    professional_plan: Optional[str] = None
    enterprise_plan: Optional[str] = None
    sort_order: Optional[int] = None
    status: Optional[int] = None


class PackageFeatureResponse(PackageFeatureBase):
    """套餐功能对照响应"""
    id: int
    created_at: Optional[datetime] = None
    updated_at: Optional[datetime] = None
    
    class Config:
        from_attributes = True


# FAQ Schemas
class FAQBase(BaseModel):
    """常见问题基础"""
    category: Optional[str] = None
    question: str
    answer: str
    tags: Optional[str] = None
    is_hot: int = 0
    sort_order: int = 0
    status: int = 1


class FAQCreate(FAQBase):
    """创建常见问题"""
    pass


class FAQUpdate(BaseModel):
    """更新常见问题"""
    category: Optional[str] = None
    question: Optional[str] = None
    answer: Optional[str] = None
    tags: Optional[str] = None
    is_hot: Optional[int] = None
    sort_order: Optional[int] = None
    status: Optional[int] = None


class FAQResponse(FAQBase):
    """常见问题响应"""
    id: int
    view_count: Optional[int] = 0
    created_at: Optional[datetime] = None
    updated_at: Optional[datetime] = None
    
    class Config:
        from_attributes = True
